package org.cqut.framework.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @author XiAoXu
 * @date 2021/5/25 15:15
 * @description
 */
public class DateUtils {

    public static Date getNowDate() {
        return new Date();
    }

    public static String formatDate(Date date) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return dateFormat.format(date);
    }

    /**
     * 是否超过一天
     */
    public static long isFinished(Date end) {
        Calendar instance = Calendar.getInstance();
        Calendar endTime = Calendar.getInstance();
        endTime.setTime(end);

        //获取毫秒
        long now = instance.getTimeInMillis();
        long last = endTime.getTimeInMillis();

        //对比时间
        return (now - last) / (1000L * 3600L * 24L);
    }
}
